

package com.hazelcast.internal.serialization.impl;

import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import com.hazelcast.nio.serialization.HazelcastSerializationException;
import com.hazelcast.nio.serialization.Serializer;
import com.hazelcast.nio.serialization.TypedStreamDeserializer;

import java.io.IOException;

public interface SerializerAdapter {

    void write(ObjectDataOutput out, Object object) throws IOException;

    Object read(ObjectDataInput in) throws IOException;

    int getTypeId();

    void destroy();

    Serializer getImpl();

    default Object read(ObjectDataInput in, Class<?> aClass) throws IOException {
        throw new HazelcastSerializationException(this + " is not implementing the " + TypedStreamDeserializer.class + " interface. Please implement this interface to deserialize for class " + aClass);
    }
}
